const { defineConfig } = require('@vue/cli-service')
var Mock = require('mockjs')
var data = Mock.mock({
  // 属性 list 的值是一个数组，其中含有 1 到 10 个元素
  'list|10': [{
    // 属性 id 是一个自增数，起始值为 1，每次增 1
    'key|+1': 1,
    "name": "@cname",
    "age|1-34": 1,
    "city": "@city(true)",
    "Tags": "@ctitle(5.8)"
  }]
})
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    onBeforeSetupMiddleware: function (devServer) {
      if (!devServer) {
        throw new Error('webpack-dev-server is not defined');
      }

      devServer.app.get('/api/list', function (req, res) {
        res.json(data.list);
      });
    },
  },
})
